// 字符串中的第一个唯一字符

import Foundation

func firstUniqChar(_ s: String) -> Int {
    var dic = [Character : Int]()
    
    for c in s {
        if let count = dic[c] {
            dic[c] = count + 1
        } else {
            dic[c] = 1
        }
    }
    
    for (i, c) in s.enumerated() {
        if dic[c] == 1{
            return i
        }
    }
    return -1
}
